package com.gzwl.controller.employee;

import com.gzwl.vo.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gzwl.service.employee.EmployeeService;
import com.gzwl.uitls.LogUtils;

@Controller
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @RequestMapping("/del/{id}")
    public String delEmployee(@PathVariable("id") int id) {
        employeeService.delEmployeeByID(id);
        LogUtils.logger.debug("测试删除");
        return "home";
    }

    @RequestMapping("/getEmployeeByID/{id}")
    public @ResponseBody
    Object getEmployeeByID(@PathVariable("id") int id) {
        Employee employee = employeeService.getEmployeeByID(id);
        return employee != null ? employee : "没有记录";
    }
}
